home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '87 / Source ƒ.sea / Source ƒ / emacs source ƒ / VT52.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-28  |  3.3 KB  |  168 lines  |  [TEXT/MARC]

  1. /*
  2.  * The routines in this file
  3.  * provide support for VT52 style terminals
  4.  * over a serial line. The serial I/O services are
  5.  * provided by routines in "termio.c". It compiles
  6.  * into nothing if not a VT52 style device. The
  7.  * bell on the VT52 is terrible, so the "beep"
  8.  * routine is conditionalized on defining BEL.
  9.  */
  10. #define    termdef    1            /* don't define "term" external */
  11.  
  12. #include        <stdio.h>
  13. #include        "estruct.h"
  14. #include    "edef.h"
  15.  
  16. #if     VT52
  17.  
  18. #define NROW    24                      /* Screen size.                 */
  19. #define NCOL    80                      /* Edit if you want to.         */
  20. #define    MARGIN    8            /* size of minimim margin and    */
  21. #define    SCRSIZ    64            /* scroll size for extended lines */
  22. #define    NPAUSE    100            /* # times thru update to pause */
  23. #define BIAS    0x20                    /* Origin 0 coordinate bias.    */
  24. #define ESC     0x1B                    /* ESC character.               */
  25. #define BEL     0x07                    /* ascii bell character         */
  26.  
  27. extern  int     ttopen();               /* Forward references.          */
  28. extern  int     ttgetc();
  29. extern  int     ttputc();
  30. extern  int     ttflush();
  31. extern  int     ttclose();
  32. extern  int     vt52move();
  33. extern  int     vt52eeol();
  34. extern  int     vt52eeop();
  35. extern  int     vt52beep();
  36. extern  int     vt52open();
  37. extern    int    vt52rev();
  38. extern    int    vt52kopen();
  39. extern    int    vt52kclose();
  40.  
  41. #if    COLOR
  42. extern    int    vt52fcol();
  43. extern    int    vt52bcol();
  44. #endif
  45.  
  46. /*
  47.  * Dispatch table. All the
  48.  * hard fields just point into the
  49.  * terminal I/O code.
  50.  */
  51. TERM    term    = {
  52.         NROW-1,
  53.         NCOL,
  54.     MARGIN,
  55.     SCRSIZ,
  56.     NPAUSE,
  57.         &vt52open,
  58.         &ttclose,
  59.     &vt52kopen,
  60.     &vt52kclose,
  61.         &ttgetc,
  62.         &ttputc,
  63.         &ttflush,
  64.         &vt52move,
  65.         &vt52eeol,
  66.         &vt52eeop,
  67.         &vt52beep,
  68.         &vt52rev
  69. #if    COLOR
  70.     , &vt52fcol,
  71.     &vt52bcol
  72. #endif
  73. };
  74.  
  75. vt52move(row, col)
  76. {
  77.         ttputc(ESC);
  78.         ttputc('Y');
  79.         ttputc(row+BIAS);
  80.         ttputc(col+BIAS);
  81. }
  82.  
  83. vt52eeol()
  84. {
  85.         ttputc(ESC);
  86.         ttputc('K');
  87. }
  88.  
  89. vt52eeop()
  90. {
  91.         ttputc(ESC);
  92.         ttputc('J');
  93. }
  94.  
  95. vt52rev(status)    /* set the reverse video state */
  96.  
  97. int status;    /* TRUE = reverse video, FALSE = normal video */
  98.  
  99. {
  100.     /* can't do this here, so we won't */
  101. }
  102.  
  103. #if    COLOR
  104. vt52fcol()    /* set the forground color [NOT IMPLIMENTED] */
  105. {
  106. }
  107.  
  108. vt52bcol()    /* set the background color [NOT IMPLIMENTED] */
  109. {
  110. }
  111. #endif
  112.  
  113. vt52beep()
  114. {
  115. #ifdef  BEL
  116.         ttputc(BEL);
  117.         ttflush();
  118. #endif
  119. }
  120.  
  121. vt52open()
  122. {
  123. #if     V7 | BSD
  124.         register char *cp;
  125.         char *getenv();
  126.  
  127.         if ((cp = getenv("TERM")) == NULL) {
  128.                 puts("Shell variable TERM not defined!");
  129.                 exit(1);
  130.         }
  131.         if (strcmp(cp, "vt52") != 0 && strcmp(cp, "z19") != 0) {
  132.                 puts("Terminal type not 'vt52'or 'z19' !");
  133.                 exit(1);
  134.         }
  135. #endif
  136.         ttopen();
  137. }
  138.  
  139. vt52kopen()
  140.  
  141. {
  142. }
  143.  
  144. vt52kclose()
  145.  
  146. {
  147. }
  148.  
  149.  
  150. #if    FLABEL
  151. fnclabel(f, n)        /* label a function key */
  152.  
  153. int f,n;    /* default flag, numeric argument [unused] */
  154.  
  155. {
  156.     /* on machines with no function keys...don't bother */
  157.     return(TRUE);
  158. }
  159. #endif
  160. #else
  161.  
  162. vt52hello()
  163.  
  164. {
  165. }
  166.  
  167. #endif
  168.